package com.cssy.xxkj.basic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicStapleUnitDAO;
import com.cssy.xxkj.basic.entity.BasicStapleUnitDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-10
 */
public class BasicStapleUnitDAOImpl extends SqlMapClientDaoSupport implements BasicStapleUnitDAO {

    /**
     * 插入数据
     * @param basicStapleUnitDO
     * @return 插入数据的主键
     */
    public String insertBasicStapleUnitDO(BasicStapleUnitDO basicStapleUnitDO) throws DataAccessException{
        Object id = getSqlMapClientTemplate().insert("BasicStapleUnit.insert", basicStapleUnitDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicStapleUnitDO
     * @return 查出的记录数
     */
    public Integer countBasicStapleUnitDOByExample(BasicStapleUnitDO basicStapleUnitDO) throws DataAccessException{
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicStapleUnit.countByDOExample", basicStapleUnitDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicStapleUnitDO
     * @return 受影响的行数
     */
    public Integer updateBasicStapleUnitDO(BasicStapleUnitDO basicStapleUnitDO) throws DataAccessException{
        int result = getSqlMapClientTemplate().update("BasicStapleUnit.update", basicStapleUnitDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicStapleUnitDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicStapleUnitDO> findListByExample(BasicStapleUnitDO basicStapleUnitDO) throws DataAccessException{
        List<BasicStapleUnitDO> list = getSqlMapClientTemplate().queryForList("BasicStapleUnit.findListByDO", basicStapleUnitDO);
        return list;
    }

    /**
     * 根据主键获取basicStapleUnitDO
     * @param id
     * @return basicStapleUnitDO
     */
    public BasicStapleUnitDO findBasicStapleUnitDOByPrimaryKey(String id) throws DataAccessException{
        BasicStapleUnitDO basicStapleUnitDO = (BasicStapleUnitDO) getSqlMapClientTemplate().queryForObject("BasicStapleUnit.findByPrimaryKey", id);
        return basicStapleUnitDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicStapleUnitDOByPrimaryKey(String id) throws DataAccessException{
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicStapleUnit.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<BasicStapleUnitDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicStapleUnitDO> list = getSqlMapClientTemplate().queryForList("BasicStapleUnit_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicStapleUnit_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		int result = (Integer)getSqlMapClientTemplate().queryForObject("BasicStapleUnit_ex.deleteBizRemoved", id);
        return result;
	}

}